#include "precompiled.h"
#include "sslclient.h"
#include "common.h"
#include <protocol/message.h>

namespace Opl
{
	namespace Helpers
	{
		class SslClientPrivate
		{
			public:
				SslClientPrivate()
				{}
				~SslClientPrivate() {}
				QString host;
				int port;
		};


		SslClient::SslClient(const QString& host, int port) :
			Ssl::SslBase(0), O_PRIVATE_CREATE(SslClient)
		{
			O_D(SslClient);
			d->host = host;
			d->port = port;
			logger()->debug("Create SslClient:%1:%2", host, port);
		}

		SslClient::~SslClient()
		{
			O_PRIVATE_DELETE;
		}

		void SslClient::start()
		{
			O_D(SslClient);
			logger()->info("SslClient::start(host=%1, port=%2)", d->host, d->port);
			QSslSocket* soc = new QSslSocket;
			setSocket(soc);
			Ssl::SslBase::start();
			soc->connectToHostEncrypted(d->host, d->port);
			setStatusInternal(Connecting);
		}

	}
}
